package com.herench.bs.handler;

import com.herench.bs.agent.IOutpatientClinicAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

/**
 * Created by lenovo on 2017/10/31.
 */
@Component
@Handler(code = "101002" ,name="检查报告详情查询")
public class LoadExamDetailsHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String repId = requestMessage.getArgsPropertyStringValue("repId");
        Assert.notNull(repId, "repId 不可为空！");
        String cardNo = requestMessage.getArgsPropertyStringValue("patientId");
        Assert.notNull(cardNo, "cardNo 不可为空！");
        IOutpatientClinicAgent outpatientClinicAgent = getCleverClinicContext().getApplicationContext().getBean(IOutpatientClinicAgent.class);
        Map<String,Object> res = outpatientClinicAgent.loadExamDetails(repId,cardNo);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage,res);
        return responseMessage;
    }
}
